import React from 'react'

export default function Demo() {
  const [count,setCount]=React.useState(0)
  const myRef=React.useRef()
 
  function add(){
    setCount(count+1)
  }
 
  function reftest(){
    console.log(myRef.current.value);
  }
  return (
    <div>
      <h1>count值为:{count}</h1>
      <input type="text" ref={myRef} />
      <button onClick={add}>+1</button>
      <button onClick={reftest}>log打印myRef</button>
    </div>
  )
}
